package Main;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class Catalog {

	private ArrayList<Event> catalogEvents;
	
	public Catalog(String f)
	{
		catalogEvents=new ArrayList<Event>();
		loadEventFromFile(f);
	}
	
	private void loadEventFromFile(String catalogEventFile)
	{

		try {
			
			Scanner fileScanner = new Scanner(new FileInputStream(catalogEventFile));
			
			while(fileScanner.hasNext())
			{
				String line=fileScanner.nextLine();
				String[] splits=line.split("/");
				int capacity=Integer.parseInt(splits[3]);//getInteger(splits[3]).intValue();
				Event readEvent=new Event(splits[0],splits[1],splits[2],capacity);
				catalogEvents.add(readEvent);
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public String toString()
	{
		String str="Catalog: " + "\n";
		for(Event e : catalogEvents)
		{
			str+=e + "\n";
		}
		return str;
	}
	
}
